#include "app.h"

#define START_STK_SIZE      128
#define START_TASK_PRIO     0
TaskHandle_t                StartTask_Handler;

static int8_t app_drv_init(void)
{
    int8_t ret = SUCCESS;
    ret = hal_SW_iic_init();
		ret = hdl_mpu6050_6dof_init();
    // ret = hdl_spi_init(SPI2,0);
    // ret = hdl_nrf24l01_init();
    // DBG_INFO("app_drv_init:%d\r\n",ret);
    return ret;
}

static void app_task_init(void *pvParameters)
{
    taskENTER_CRITICAL();
    appl_main_framework_task_init();
    hal_serial_console_task_init();
    vTaskDelete(StartTask_Handler);
    taskEXIT_CRITICAL();
}

int8_t apl_main_init(void)
{
	int8_t ret = SUCCESS;
    ret |= app_drv_init();

    DBG_MSG("MAX task priority:%d\r\n",configMAX_PRIORITIES);
    xTaskCreate((TaskFunction_t) app_task_init,
                (const char*)   "app_task_init",
                (uint16_t)      START_STK_SIZE,
                (void*)         NULL,
                (UBaseType_t)   START_TASK_PRIO,
                (TaskHandle_t*) &StartTask_Handler);

    return SUCCESS;
}

